package pseudoAssemblerCompiler.twopassassembler.view.ui.autocomplete;

import org.eclipse.jface.fieldassist.IContentProposal;

/**
 * User: Selivanov
 * Date: 08.05.12
 * Time: 1:33
 */
class TextDisplayFormatContentProposal<T> implements IContentProposal {
    private TextDisplayFormat<T> displayFormat;
    private T element;

    TextDisplayFormatContentProposal(TextDisplayFormat<T> displayFormat, T element) {
        this.displayFormat = displayFormat;
        this.element = element;
    }

    @Override
    public String getContent() {
        return displayFormat.getDisplayName(element);
    }

    @Override
    public int getCursorPosition() {
        return getContent().length();
    }

    @Override
    public String getLabel() {
        return displayFormat.getDisplayName(element);
    }

    @Override
    public String getDescription() {
        return displayFormat.getDescription(element);
    }
}
